using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WindowsLive.Writer.Api;

namespace ImFeelingLucky
{
    public partial class frmOptions : Form
    {
        PluginSettings m_settings;

        public frmOptions(PluginSettings settings)
        {
            InitializeComponent();
            m_settings = settings;
            ApplySettings();
        }

        public void ApplySettings()
        {
            chbxAuto.Checked = m_settings.AutoInsert;
            chbxOpen.Checked = m_settings.OpenInNewWindow;
            chFormatting.Checked = m_settings.LeaveFormatting;
            chbxAuto_Click(this, null);           
        }

        private void chbxAuto_Click(object sender, EventArgs e)
        {
            if (chbxAuto.Checked)
            {
                chbxOpen.Enabled = true;
                chFormatting.Enabled = true;
            }
            else
            {
                chbxOpen.Enabled = false;
                chFormatting.Enabled = false;
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            m_settings.AutoInsert = chbxAuto.Checked;
            m_settings.OpenInNewWindow = chbxOpen.Checked;
            m_settings.LeaveFormatting = chFormatting.Checked;
            this.Close();
        }
    }
}